$(function () {
    getlist()

    // 获取对应用户下的店铺列表信息
    function getlist(e) {
        $.ajax({
            url: "/shopadmin/getshoplist",
            type: "get",
            dataType: 'json',
            success: function (data) {
                if (data.success) {
                    handleList(data.shopList);
                    handleUser(data.user);
                }
            }
        })
    }
    // 用户名
    function handleUser(data) {
        $('#user-name').text(data.name);
    }
    // 店铺列表
    function handleList(data) {
        var html = '';
        data.map(function (item, index) {
            html += '<div class="row row-shop"><div class="col-40">' +
                item.shopName+'</div><div class="col-40">' +
                shopStatus(item.enableStatus)+'</div><div class="col-20">' +
                goShop(item.enableStatus,item.shopId)+'</div></div>';
        })
        $('.shop-wrap').html(html);
    }
    // 店铺状态
    function shopStatus(status) {
        if (status==0) {
            return '审核中';
        } else if (status==-1) {
            return '店铺非法';
        } else if (status==1) {
            return '审核通过';
        }
    }
    // 通往店铺
    function goShop(status, id) {
        if (status != 0 && status != -1) {
            return '<a href="/shopadmin/shopmanagement?shopId='+ id +'">进入</a>';
        } else {
            return '';
        }
    }
})